#include "ConstantValue.h"
#include "../Exceptions.h"
#include "../GeneralVisitor.h"

ConstantValue::ConstantValue(long iValue)
{
    fValue.LongValue = iValue;
    fType = LongInteger;
}

ConstantValue::ConstantValue(double iValue)
{
    fValue.DoubleValue = iValue;
    fType = Double;
}

ConstantValue::ConstantValue(string *iValue)
{
    fValue.StringValue = iValue;
    fType = String;
}

ConstantValue::~ConstantValue()
{
    if(fType == String)
        delete fValue.StringValue;
}

ExpressionType* ConstantValue::GetType(map<string, ExpressionType*>&, string)
{
    return new ExpressionType(fType, false);
}

void ConstantValue::Accept(GeneralVisitor* iVisitor)
{
    iVisitor->Visit(this);
}
